<?php

if(!defined('_HTML_SEARCH_')) {
define('_HTML_SEARCH_', 1);

function flep_html_search_init($type){
  flep_structure($data, $type);
  $data['page_idx'] = isset($_GET['idx'])?intval($_GET['idx']):0;
  $data['offset'] = $data['page_idx']*_FLEP_MAX_ROWS_;
  if (isset($_GET['id'])) {
      $data['where'][0] = sprintf("`%s`.`id`='%s'", $data['table'], flep_decode($_GET['id']));
  } else {
    if(isset($_GET['search'])){
      $data['search'] = flep_db_escape($_GET['search']);
    }
  }
  return $data;
}

function flep_html_search($page, $dest = 'page'){
?>
  <label>Search:</label>&nbsp;
  <input type="text" id="search" onkeyup="(event.keyCode === 13 )? flep_buscar('<?php echo $page."','".$dest;?>') : false;" value="<?php
    echo (isset($_GET['search']) ? $_GET['search']:'');
  ?>" size="20">
  <img src="request.php?res=search.png" title="Search" onclick="flep_buscar('<?php echo $page."','".$dest;?>');">
<?php
}

}
?>
